import tensorflow as tf 

t = tf.constant('cafe')
print(tf.strings.length(t))
print(tf.strings.length(t, unit = 'UTF8_CHAR'))
print(tf.strings.unicode_decode(t,'UTF8'))

print('*'*60)

t = tf.constant(['cafe','coffee','咖啡'])
print(tf.strings.length(t))
print(tf.strings.length(t, unit = 'UTF8_CHAR'))
print(tf.strings.unicode_decode(t,'UTF8'))  # raggedTensor : 不规则的tensor 每行数据量可以不一致